@/*
    表单中WangEditor框标签中各个参数的说明:
    id : id
    fileListName : 所有所有以选择的文件的統一名称
    value : 值

@*/
@if(isEmpty(folderId)){
@	folderId="0";
@}
@if(isEmpty(accept)){
@	accept=null;
@}
@var map = null;
@if(!isEmpty(value)){
@   map = value;
@}
@if(isEmpty(parent)){
@   parent = false;
@}
<div class="form-group has-feedback">
    @if(!isEmpty(row)){
    <label class="lab"></label>
    @}
    <div class="ele ${isEmpty(name)?'ele-fit':''}">
        <a  href="javascript:void(0);"  onclick="onClickUpFile()" class="hisui-linkbutton" data-options="iconCls:'icon-upload-cloud',plain:true">
            	上传本地文件
        </a>
        <a  href="javascript:void(0);" onclick="openAddFile()"  class="hisui-linkbutton" data-options="iconCls:'icon-paper-arrow-up',plain:true">
            	从文件夹中选择
        </a>
        <div id="file_${id}" style="width: 100%; background: cornsilk;margin-top: 5px;">
        </div>
    </div>
    <span class="hidden" id="${id}BtnId">
    </span>
    <div id="${id}_progressBar" class="progress progress-striped progressBar">
        <div style="width: 0%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="0" role="progressbar" class="progress-bar progress-bar-info ">
        </div>
    </div>
</div>
<script type="text/javascript">
    var fileIndex =  99;
    var _wu_${id} = null;

    function openAddFile() {
        if(${parent}){
            Sys.open_p("添加文件","${backendPath}/pan/file/select",["100%","100%"],function (layero, index, iframeWin) {
                iframeWin.AddFile.setResponse(addFile);
            })
        }else {
            Sys.open("添加文件","${backendPath}/pan/file/select",["100%","100%"],function (layero, index, iframeWin) {
                iframeWin.AddFile.setResponse(addFile);
            })
        }
    }

    function addFile(key, values) {
        var _html = '';
        _html += '<div style="margin-right: 10px;margin-left: 10px">';
        _html += '<span class="hisui-icon icon-upload-cloud" style="margin-right: 10px;margin-left: 5px"></span>'+ values;
        _html += '<a  href="javascript:void(0);" onclick="delFile(this)" id="fileup_'+fileIndex+'"><span class="hisui-icon icon-remove">&nbsp;</span></a>';
        _html += '<input class="textbox" style="width:100%" type="hidden" id="fileup_'+fileIndex+'" name="${fileListName}" value="'+ key+'">';
        _html += '<hr style="margin: 0px">';
        _html += '<div>';
        $("#file_${id}").append(_html);
        fileIndex++;
    }
    function delFile(obj) {
        $(obj).parent().remove();
    }

    function upLoadFile(response) {
        addFile(response.file.attachmentId,response.file.fileName)
    }

    function onClickUpFile() {
        _wu_${id}.setData({source:"${sourse!}",folderId:${folderId!}});
        $("#${id}BtnId").find("label").trigger("click");
        _wu_${id}.setUploadCompleteEvent(upLoadFile);
    }
    $(function () {
        _wu_${id} = new $WebUpload("${id}");
        _wu_${id}.setUploadUrl(Sys.ctxPath + '/pan/file/upload');
        _wu_${id}.setUploadAccept(${accept});
        _wu_${id}.init();
    });
</script>
@ if(!isEmpty(value)){
@for(ele in value){
<script>
    var fileIndex = 98;
    var _html = '';
    _html += '<div style="margin-right: 10px;margin-left: 10px">';
    _html += '<span class="hisui-icon icon-upload-cloud" style="margin-right: 10px;margin-left: 5px"></span>${ele.originalName}';
    _html += '<a  href="javascript:void(0);" onclick="ArticleInfoDlg.delItem(this)" id="fileup_'+fileIndex+'"><span class="hisui-icon icon-remove">&nbsp;</span></a>';
    _html += '<input class="textbox" style="width:100%" type="hidden" id="fileup_'+fileIndex+'" name="${fileListName}" value="${ele.id}">';
    _html += '<hr style="margin: 0px">';
    _html += '<div>';
    $("#file_${id}").append(_html);
    fileIndex--;
</script>
@}
@}
